﻿using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;

namespace EGEngine
{
    [CustomEditor(typeof(UIModule))]
    public class UIModuleInspector : Editor
    {
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            var t = target as UIModule;
            if (GUILayout.Button("刷新PageType"))
            {
                string path = $"{Application.dataPath}/Engine/Runtime/Manager/UI/EUIPageType.cs";
                string text = "namespace EGEngine\n" +
                              "{\n" +
                              "    public enum EUIPageType\n" +
                              "    {\n";
                foreach (var layer in t.UILayers)
                {
                    text += $"        {layer},\n";
                }

                text += "    }\n" +
                        "}";
                File.WriteAllText(path, text, Encoding.UTF8);
            }
        }
    }
}